<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{{ new.title }}</title>
    <link href="{{ url_for('static',filename='css/index/001.css',_external=True) }}" rel="stylesheet" type="text/css"/>
    <link href="{{ url_for('static',filename='css/index/gb_styles.css',_external=True) }}" rel="stylesheet"
          type="text/css" media="all"/>
    <script type=text/javascript src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
    <style type="text/css">
        .user_content p {
            float: left;
        }

        .username {
            max-width: 80px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    </style>
</head>
<body>
<div class="ding wi"
     style='background-image: url("{{ url_for('static',filename='css/images/top.jpg',_external=True) }}");width:77%'>
    <div class="sj fl">欢迎您！&nbsp;&nbsp;&nbsp;现在时间：
        <script type="text/javascript">
            function initArray() {
                for (i = 0; i < initArray.arguments.length; i++)
                    this[i] = initArray.arguments[i];
            }

            var isnMonths = new initArray("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
            var isnDays = new initArray("周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日");
            today = new Date();
            hrs = today.getHours();
            min = today.getMinutes();
            sec = today.getSeconds();
            clckh = "" + ((hrs > 12) ? hrs - 12 : hrs);
            clckm = ((min < 10) ? "0" : "") + min;
            clcks = ((sec < 10) ? "0" : "") + sec;
            clck = (hrs >= 12) ? "下午" : "上午";
            var stnr = "";
            var ns = "0123456789";
            var a = "";

            function getFullYear(d) {
                yr = d.getYear();
                if (yr < 1000)
                    yr += 1900;
                return yr;
            }
        </script>
        <script type="text/javascript">
            //下面各行分别是一种风格，把不需要的删掉即可
            document.write("" + getFullYear(today) + "年" + "," + isnMonths[today.getMonth()] + "月" + today.getDate() + "日," + isnDays[today.getDay()] + "");
        </script>
    </div>
    <div class="sc fr">
        {% if user.is_login %}
            <a href="{{ url_for('account.center') }}"><img src="{{ user.head_img }}" style="width: 28px;height: 28px;border-radius: 50%;" alt=""/></a>
            <a class="one" style="color: blue" href="{{ url_for('account.center') }}">{{ user.username }}</a>&nbsp;|&nbsp;
            <a class="one" href="{{ url_for('account.login_out') }}">登出</a>
        {% else %}
            <a href="{{ url_for('account.login') }}?next=news/?new={{ new_id }}" class="one">登录</a>&nbsp;|&nbsp;
            <a class="one" href="{{ url_for('account.register') }}">注册</a>
        {% endif %}
    </div>
</div>
<div class="nav wi yh"
     style='background-image: url("{{ url_for( 'static',filename='css/images/dhbj.jpg',_external=True ) }}");width:77%'>
    <ul>
        <li><a href="{{ url_for('index.home') }}">首页</a></li>
        {% for kind in kind_list %}
            <li><a href="{{ url_for('kind.cat',type_id=kind.type_id) }}">{{ kind.type }}</a></li>
        {% endfor %}
    </ul>
</div>
<div class="g6 bgf wi"></div>

<div class="g6 bgf wi"></div>

<div class="nm w2" style="margin-left: 180px">
    <div class="nml fl">
        <div class="lmti"
             style='background: url("{{ url_for( 'static',filename='css/images/lmdh.jpg',_external=True ) }}'>
            <strong>栏目导航</strong>
        </div>
        <div class="lmtx b1"
             style='background: url("{{ url_for( 'static',filename='css/images/lmtx.jpg',_external=True ) }}")'>
            <ul>
                <li><a href="{{ url_for('index.home') }}">首页</a></li>
                {% for kind in kind_list %}
                    <li>
                        <a href="{{ url_for('kind.cat',type_id=kind.type_id) }}">{{ kind.type }}</a>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="g10"></div>
    </div>
    <div class="nmr fr" style="width: 76%;margin-right: 6%">
        <div class="wz"
             style='background: url("{{ url_for( 'static',filename='css/images/wzbg.jpg',_external=True ) }}'>
            <span>您现在的位置：
                <a href="{{ url_for('index.home') }}">首页</a>&nbsp;>&nbsp;
                <a href="{{ url_for('kind.cat',type_id=new_type.type_id) }}">{{ new_type.type }}</a>
            </span>
        </div>
        <div class="nei n1">
            <div class="con">
                <h1>{{ new.title }}</h1>
                <div class="info">
                    发布时间：{{ new.create_time }}
                    来源：{{ new.news_from }}
                    查看：{{ new.click_num }}次
                    收藏：{{ new.store_up_num }}
                    <button id="fav_id" style="position: relative;left: 15px">{{ fav }}</button>
                </div>
                <div class="new_content" style="display:none;">
                    {{ new.content }}
                </div>
                <div class="cont">
                    <script>
                        var data = $(".new_content");//获取隐藏div里的文字
                        $('.cont').html(data.text());//通过html()方法将文字输出到div中，转义成html代码
                    </script>
                </div>
            </div>
            <div class="tag"></div>
            <div class="xgx" style="margin-top: 80px">
                <p hidden id="new_id">{{ new_id }}</p>
                <strong style="font-size: 18px;">评论({{ new.comment_num }}条)：</strong>
                <div style="height: 30px"></div>
                <ul>
                    {% for item in items %}
                        <li>
                            <div style="height:100px;font-size: 13px" class="user_content">
                                <p>
                                    <img src="{{ item['comments_user'].head_img }}"
                                         style="width: 28px;
                            height: 28px;display: flex;border-radius: 50%;align-items: center;justify-content: center;overflow: hidden;">
                                </p>
                                <p style="font-size: 14px;margin-top: 12px" class="username">{{ item['comments_user'].username }}</p>
                                <p style="font-size: 14px;margin-top: 12px">:</p>
                                <div style="width: 750px;height: 100px;float: right">
                                    <p id="comment" style="font-size: 14px;margin-top: 12px">
                                        {{ item['comment'].content }}
                                    </p>
                                </div>
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            </div>
            <div style="margin-top: 50px">
                <strong style="font-size: 16px;">我要评论:</strong>
                <textarea id="js-pl-textarea" rows="6" cols="40" name="content"
                          style="width: 600px;margin-left: 10px"></textarea>
                <button id="js-pl-submit" style="width: 50px;position: relative;bottom: 7px;left: 10px;">
                    发送
                </button>
            </div>
        </div>
    </div>
    <div class="c"></div>
</div>
<div class="g10 wi"></div>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" style="width: 77%">
    <tr>
        <td height="100" align="center"
            background="{{ url_for('static',filename='css/images/jcdzz_36.jpg',_external=True) }}" bgcolor="#FFFFFF"
            style="font-family:arial; line-height:26px;"> 免责声明:如果侵犯了你的权益，请发邮件至：wang_call@163.com，我们会及时删除侵权内容，谢谢合作！<br/>
            Copyright © 2018 蜀ICP备88888888号 2018 All Rights Reserved.<br/>
        </td>
    </tr>
</table>
<script type="text/javascript">
    //添加评论
    $('#js-pl-submit').on('click', function () {
        var comments = $("#js-pl-textarea").val()
        var new_id = $("#new_id").text()
        if (comments == "") {
            alert("评论不能为空")
            return
        }
        var csrftoken = $('meta[name=csrf-token]').attr('content')
        $.ajax({
            type: "POST",
            url: "{{ url_for('news.details') }}",
            data: {"comment": comments, "new_id": new_id, "post_type": "comment"},
            dataType: 'json',
            async: true,
            beforeSend: function (xhr, settings) {
                if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
                    xhr.setRequestHeader("X-CSRFToken", csrftoken)
                }
            },
            success: function (data) {
                if (data.status == 'fail') {
                    alert("请登录后再进行评论")
                    window.location.href = "/account/login/";
                } else if (data.status == 'success') {
                    window.location.reload();//刷新当前页面.
                }
            },
        });
    });
    //添加收藏
    $('#fav_id').on('click', function () {
        var new_id = $("#new_id").text()
        var is_fav = $("#fav_id").text()
        var csrftoken = $('meta[name=csrf-token]').attr('content')
        $.ajax({
            type: "POST",
            url: "{{ url_for('news.details') }}",
            data: {"new_id": new_id,"is_fav":is_fav},
            dataType: 'json',
            async: true,
            beforeSend: function (xhr, settings) {
                if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
                    xhr.setRequestHeader("X-CSRFToken", csrftoken)
                }
            },
            success: function (data) {
                if (data.status == 'fail') {
                    alert("请登录后再进行收藏")
                    window.location.href = "/account/login/";
                } else if (data.status == 'success') {
                    window.location.reload();//刷新当前页面.
                }
            },
        });
    });
</script>
</body>
</html>